import axios from "axios";
import {Environment} from "@/environment";

export class Http {

    private static instance: Http = new Http();

    /**
     * get请求
     * 
     * @param url 
     * @param params 
     */
    async get(url: string, params: any) {
        console.log("Environment.BASEURL",Environment.BASEURL);
        return axios.get(Environment.BASEURL + `${url}`, {
            params
        });
    }

    /**
     * get请求
     * 
     * @param url 
     * @param params 
     */
    async post(url: string, params: any) {
        return axios.post(Environment.BASEURL + `${url}`, params);
    }

    /**
     * 获取实例
     *
     * @static
     * @return {*} 
     * @memberof Http
     */
    static getInstance() {
        if (this.instance) {
            return this.instance;
        }
        this.instance = new Http();
        return this.instance;
    }
}